package com.haorui.lygyd.authority.authentication;

import lombok.Getter;
import lombok.Setter;
import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.SpringSecurityCoreVersion;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.web.authentication.WebAuthenticationDetails;

import java.util.Collection;

/**
 * @author 陈刚
 * @version 1.0
 * @project znsm
 * @package com.haorui.znsm.authority.authentication
 * @createDate 2018-03-16 14:18
 * @modfiyDate
 * @function
 */
public class AccountAuthenticationToken extends AbstractAuthenticationToken {


    private String userName;
    private String password;
    @Getter
    @Setter
    private WebAuthenticationDetails webAuthenticationDetails;

    /**
     *
     * @param userName
     * @param password
     */
    public AccountAuthenticationToken(String userName, String password) {
        super(null);
        this.userName = userName;
        this.password = password;
        super.setAuthenticated(false);
    }
    public AccountAuthenticationToken(String userName, String password,WebAuthenticationDetails webAuthenticationDetails) {
        super(null);
        this.userName = userName;
        this.password = password;
        this.webAuthenticationDetails=webAuthenticationDetails;
        super.setAuthenticated(false);
    }


    @Override
    public Object getPrincipal() {
        return this.userName;
    }
    @Override
    public Object getCredentials() {
        return this.password;
    }


    @Override
    public void eraseCredentials() {
        super.eraseCredentials();
        password = null;
    }
}
